import 'package:flutter/material.dart';
import 'package:vehicle_management/pages/user/login_page.dart';
import 'package:vehicle_management/pages/home_page.dart';
import 'package:vehicle_management/pages/user/forget_password_page.dart';
//配置路由
final routes = {
  /**
         * 命名导航路由，启动程序默认打开的是以'/'对应的界面LoginPage()
         * 凡是后面使用Navigator.of(context).pushNamed('/Home')，都会跳转到Home()，
         */
  '/': (context) => LoginPage(),
  '/Home': (context) => Home(),
  '/ForgetPassword': (context) => ForgetPassword(),
  
};
// 固定写法
var onGenerateRoute = (RouteSettings settings) {
  // 统一处理
  //获取路由名称
  final String name = settings.name;
  //获取路由名后对应的值,即将方法赋值给方法
  final Function pageContentBuilder = routes[name];
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      //跳转传参
      final Route route = MaterialPageRoute(
          //调用方法
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      final Route route =
          MaterialPageRoute(builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
};
